Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Designing Applications > Designing XPage Applications > Coloring Specific View Rows Using a Dynamic Table and CSS in XPages
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Community articleColoring Specific View Rows Using a Dynamic Table and CSS in XPages
Added by ~Cheryl Elhipigenlen | Edited by ~Cheryl Elhipigenlen on February 23, 2010 | Version 2
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: XPages, CSS, Themes

I had a student ask recently about the ability to set the background color of a table row based upon a value in the data.  This is something that was pretty commonly done in traditional Domino Web Development.  In investigating how to do this I couldn't find a way to implement this using the standard View control, so I developed the following technique.

I use a dynamic html table (I showed how to implement this in my post http://xpagesblog.com/xpages-blog/2009/9/23/creating-a-dynamic-html-table-on-an-xpage.html" title="here">hereexternal link ) but this technique can be used with a Data Table as well.

Create a CSS Style sheet that will map the colors to be used to the data values from the Domino View data. In the View I'm using as a data source there is a column that contains a Status value with one of the following values in it

  • New
  • Existing
  • Terminated
  • Pending

I have the following CSS in a stylesheet resource called rowclasses.css that I will be using in this demo.

.New {
background-color: red;
}
.Existing {
background-color: blue;
}
.Terminated {
background-color: fuchsia;
}

The class definitions in the CSS stylesheet are the same as the values from the status column.

Add the style sheet as a resource for the XPage.

 

 Before the Stylesheet is applied the XPage rendered in the browser looks like the following

 


We want the individual table rows background color to be set using the colors from the CSS style sheet based upon the value from the Status column in the View data.

To review, the dynamic table uses a repeat control that has a variable called "customers" for each row of data that will be displayed.  The value in the status column can be read from that variable using the Expression Language syntax customers.Status.

To set the value of the table rows background color, select the table row.  On the Style tab of the Properties tab click the computed diamond icon next to the Class field and choose "Compute value...".


 

In the Script Editor dialog box that opens up change the language to Expression Language and type in the expression customers.Status.  Click the OK button to save the expression to the class field.


Save the XPage and preview it in the browser.  Now each rows background color will be set to the value in the CSS stylesheet based upon the value from the status column.


The status column does not have to be displayed, but it does have to be available in the data.

The style does not have to be applied to the entire row, it could be applied to one or many table cells as well.

The application with complete source code can be downloaded from my website http://www.nnsu.com" title="here">hereexternal link 

expanded Attachments (0)
collapsed Attachments (0)
expanded Versions (3)
collapsed Versions (3)
Version Comparison     
VersionDateChanged by              Summary of changes
3Apr 25, 2016, 10:07:17 AM~Fred Ektumilitetsi  
This version (2)Feb 23, 2010, 5:24:55 PM~Cheryl Elhipigenlen  
1Feb 23, 2010, 5:22:11 PM~Cheryl Elhipigenlen  
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility